package com.xayy.mgt.controller;

import cn.kawins.base.result.CheckResult;
import cn.kawins.base.result.ResultBody;
import cn.kawins.mybatis.base.BaseController;
import cn.kawins.spring.mvc.validator.Group;
import com.xayy.mgt.model.vo.SateRateAndCacheVo;
import com.xayy.mgt.model.xinwangmodel.AssessData;
import com.xayy.mgt.model.xinwangmodel.HealthEntity;
import com.xayy.mgt.model.xinwangmodel.SateLinkData;
import com.xayy.mgt.service.GenerateAssessDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * 生成评估数据
 * @author plq
 */
@Api(tags = "生成评估数据")
@RestController
@RequestMapping(value = "/generateAssessData1")
@Slf4j
public class GenerateAssessDataController extends BaseController<AssessData> {

    private final GenerateAssessDataService generateAssessData;

    public GenerateAssessDataController(GenerateAssessDataService generateAssessData){
        this.generateAssessData = generateAssessData;
    }

    @GetMapping(value = "/execute")
    @ApiOperation(value = "根据实际数据生成评估数据",httpMethod = "GET",response = SateLinkData.class,notes = "生成评估数据-根据实际数据生成评估数据")
    public ResultBody generateAssessData(
            @ApiParam("region:=1 卫星vs卫星 ,= 2 卫星vs地面站 ,= 3 地面站vs卫星")   @RequestParam("region") String region,
            @RequestParam("nodeId") Long nodeId,
            @RequestParam("time") Date time
    ) {
        CheckResult<Object> result = generateAssessData.generateAssessData(region,nodeId,time);
        return ResultBody.success(result);
    }

    @GetMapping(value = "/siteRateAndCache")
    @ApiOperation(value = "获取评估的卫星速率以及缓存",httpMethod = "GET",response = SateRateAndCacheVo.class,notes = "生成评估数据-获取评估的卫星速率以及缓存")
    public ResultBody siteRateAndCache(@RequestParam("nodeId") Long nodeId,@RequestParam("time") Date time) {
        CheckResult<Object> result = generateAssessData.siteRateAndCache(nodeId,time);
        return ResultBody.success(result);
    }

    @PostMapping(value = "/healthAssess")
    @ApiOperation(value = "健康评估",httpMethod = "POST",response = String.class,notes = "生成评估数据-健康评估")
    public ResultBody healthAssess(@Validated(Group.Insert.class) @RequestBody HealthEntity healthEntity) {
        CheckResult<Object> result = generateAssessData.healthAssess(healthEntity);
        return ResultBody.success(result);
    }



}
